﻿Imports System.Windows.Forms

Public Class frmTambahAntrian

    Public ReadOnly Property TabelSumber As String
        Get
            Return txtTblSumber.Text
        End Get
    End Property
    Public ReadOnly Property TabelTujuan As String
        Get
            Return txtTblTujuan.Text
        End Get
    End Property

    Private Sub OK_Button_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles OK_Button.Click
        'Cek value yang kosong
        If String.IsNullOrWhiteSpace(txtTblSumber.Text) Or String.IsNullOrWhiteSpace(txtTblTujuan.Text) Then
            MsgBox("Harap isi Tabel sumber da Tabel tujuan.", vbExclamation, "Data belum lengkap")
            Return
        End If

        'Cek apakah tabel benar-benar ada di DataSource
        Dim pesan As String = ""
        Dim cn As SqlClient.SqlConnection = ConnectSQL(GlobalSourceConnectionString, pesan)
        If pesan = String.Empty Then
            If Not IsTableExists(cn, txtTblSumber.Text) Then
                MsgBox("Maaf, tabel yang Anda masukan tidak ditemukan.", vbExclamation, "Tabel tidak ada")
                Return
            End If
        Else
            MsgBox("Maaf, ada kesalahan saat melakukan koneksi dengan database." & _
                    vbCrLf & pesan, vbCritical, "Gagal koneksi database")
            Return
        End If
        cn.Close()

        Me.DialogResult = System.Windows.Forms.DialogResult.OK
        Me.Close()
    End Sub

    Private Sub Cancel_Button_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Cancel_Button.Click
        Me.DialogResult = System.Windows.Forms.DialogResult.Cancel
        Me.Close()
    End Sub

End Class
